package com.learn;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class JdbcDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	public void addProduct(String name){
		String sql = "insert into product (pname) values('"+name+"')";
		jdbcTemplate.execute(sql);
	}
	
	public void addProductBatch(String... names){
		for(String name:names){
			String sql = "insert into product (pname) values('"+name+"')";
			jdbcTemplate.execute(sql);
			throw new NullPointerException();
		}
	}
}
